'use strict';
module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.createTable('UsersGoods', {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER
      },
      userId: {
        type: Sequelize.INTEGER,
        allowNull: false,
        primaryKey: true,
        onDelete: 'CASCADE',
        onUpdate: 'CASCADE',
        references: {
          model: 'Users',
          key: 'id'
        }
      },
      goodsId: {
        type: Sequelize.INTEGER,
        allowNull: false,
        primaryKey: true,
        onDelete: 'CASCADE',
        onUpdate: 'CASCADE',
        references: {
          model: 'Goods',
          key: 'id'
        }
      },
      goodsPrizeId: {
        type: Sequelize.INTEGER,
        allowNull: false,
        primaryKey: true,
        onDelete: 'CASCADE',
        onUpdate: 'CASCADE',
        references: {
          model: 'GoodsPrizes',
          key: 'id'
        }
      },
      number: {
        allowNull: false,
        type: Sequelize.INTEGER,
        defaultValue: '0'
      },
      status: {
        allowNull: false,
        type: Sequelize.INTEGER(1),
        comment: '0、参与的抽奖 1、发起的抽奖 2、已经中奖',
        defaultValue: '0'
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.BIGINT(13)
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.BIGINT(13)
      }
    }, {
      timestamps: false,
      charset: 'utf8mb4',
      collate: 'utf8mb4_general_ci',
      comment: '用户抽奖表',
    });
  },
  down: (queryInterface, Sequelize) => {
    return queryInterface.dropTable('UsersGoods');
  }
};